package com.hczt.xhminiapp.db.repository;

import com.hczt.xhminiapp.db.entity.SysUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface SysUserRepository extends JpaRepository<SysUser, String>, JpaSpecificationExecutor<SysUser> {

    List<SysUser> findByUsername(String username);

    SysUser findByUsernameAndUserIdNot(String username, String userId);

    @Modifying
    @Query(value = "update t_sys_user u set u.enabled = :enableFlag where u.user_id = :userId",nativeQuery = true)
    void setFixedEnableFor(@Param("userId") String userId, @Param("enableFlag") String enableFlag);
}
